package com.micro.frog.fortune;

import java.net.InetAddress;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

/**
 * @author Jason.lv
 * @since 2022/2/22 15:24
 */
@Slf4j
@SpringBootApplication
@MapperScan(basePackages = "com.micro.frog.fortune.dao.mapper")
@EnableFeignClients(basePackages = {"com.micro.frog.*.api"})
public class Application {

    public static void main(String[] args) throws Exception {

        ConfigurableApplicationContext application = SpringApplication.run(Application.class, args);

        Environment env = application.getEnvironment();
        String contextPath = env.getProperty("server.servlet.context-path");
        contextPath = contextPath == null ? "" : contextPath;
        log.info("\n----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "Local: \t\t http://localhost:{}{}\n\t" +
                "External: \t http://{}:{}{}\n\t" +
                "Doc: \t http://localhost:{}{}/doc.html\n" +
                "----------------------------------------------------------",
            env.getProperty("server.port"),
            contextPath,

            InetAddress.getLocalHost().getHostAddress(),
            env.getProperty("server.port"),
            contextPath,

            env.getProperty("server.port"),
            contextPath
        );
    }

}
